﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using StructureMap;
using System.ServiceModel;
using System.Diagnostics;
using System.Threading;

namespace ChinaPetroEtlServices
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            ObjectFactory.Initialize(x =>
            {
                x.UseDefaultStructureMapConfigFile = true;
            });

            Thread t = new Thread(new ThreadStart(LoadWcfService));
            t.Start();
            
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
			{ 
				new ServiceEtl() 
			};
            ServiceBase.Run(ServicesToRun);
        }

        private static void LoadWcfService()
        {
            try
            {
                ServiceHost host = new ServiceHost(typeof(EtlContract.WCFEtlServices));
                host.Open();
                Debug.WriteLine(host.BaseAddresses.First().OriginalString);
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
    }
}
